package com.shawn.server.controller;

import com.shawn.server.service.MapService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 地图资源
 *
 * @author lenovo
 * @date 2022/11/01
 */
@Slf4j
@RestController
@RequestMapping("/baidu")
public class MapController {

    @Autowired
    private MapService mapService;


    @PostMapping("/location")
    public ResponseEntity uploadMapInfo(@RequestBody Map<String,Object> map){
        Double longitude = Double.valueOf(map.get("longitude").toString());
        Double latitude = Double.valueOf(map.get("latitude").toString());
        String addressDescription = (String) map.get("addrStr");

        mapService.uploadMapInfo(longitude,latitude,addressDescription);
        return ResponseEntity.ok("位置上传成功!");
    }

}
